
import processing.serial.*;

Serial myPort;  
char valInP;      
char valInA;
int R;
int G;
int B;
int rNo = 0;
int reset = 1;
void setup() 
{
  size(200, 200);
  String portName = Serial.list()[0];
  myPort = new Serial(this, portName, 9600);
}


void draw()
{
  
  if ( myPort.available() > 0) {  
    valInA = char(myPort.read());       
  }
  background(255); 
  switch(valInA) {
    case 'R':
      R = 231;  G = 47;  B = 39;
      break;
    case 'G':
      R = 19; G = 230; B = 50;
      break;
    case 'B':
      R = 1;  G = 104;  B = 231;
      break;
    default:
      R = 0; G = 0; B = 0;
      break;
  }
  
  fill(R,G,B);                 // set fill to light gray

  myPort.write('H'); 
  rect(50, 50, 100, 100);
    // val1 -> start horizontal
    // val2 -> start verticle
    // val3 -> length horizontal
    // val4 -> length verticle
}

